'use strict'


var $define = Object.defineProperty;

var $create = Object.create;

var $assign = Object.assign;



// yaxi全局变量
var yaxi = Object.yaxi = $create(null);



// 注册微任务
var microtask = (function () {

    var P = typeof Promise === 'function' && Promise;

    if (P && ('' + P).indexOf('[native code]') > 0)
    {
        var resolve = function (resolve) {

            resolve();
        };

        return function (fn) {

            new P(resolve).then(fn);
        }
    }

    return function (fn) {

        setTimeout(fn, 0);
    }

})();



// 继承扩展
Object.extend = function extend(classCodeFn, Class) {

    var base = this.prototype || null;
    var superclass = base ? this : null;
    var prototype = $create(base);

    if (superclass)
    {
        Class || (Class = function Class() {

            superclass.apply(this, arguments);
        });

        // 初始化类
        if (superclass.init)
        {
            superclass.init(Class);
        }
    }
    else if (!Class)
    {
        Class = function Class() {};
    }

    // 扩展方法
    Class.extend = superclass && superclass.extend || extend;
    Class.superclass = superclass;
    Class.prototype = prototype;

    prototype.constructor = Class;

    // 父类支持属性则初始化属性支持
    if (base && base.__defaults)
    {
        prototype.__defaults = $create(base.__defaults);
        prototype.__properties = $create(base.__properties);

        $define(Class, 'properties', base.__static_properties);
    }

    // 定义类
    if (classCodeFn)
    {
        classCodeFn.call(prototype, base);
    }

    return Class;
}



function throwTextError(message) {

    throw new Error(message);
}

